/*Copyright ©2015 TommyLemon(https://github.com/TommyLemon)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.*/

package zuo.biao.library.ui;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;

import zuo.biao.library.R;
import zuo.biao.library.base.BaseActivity;
import zuo.biao.library.interfaces.OnBottomDragListener;
import zuo.biao.library.util.ImageLoaderUtil;
import zuo.biao.library.util.Log;
import zuo.biao.library.util.StringUtil;

public class ShowPictureActivity extends BaseActivity implements OnBottomDragListener, OnClickListener {
    public static final String TAG = "ShowPictureActivity";

    public static final String INTENT_PIC = "INTENT_PIC";
    public static final String INTENT_NAVI = "INTENT_NAVI";

    public static Intent createIntent(Context context, String picpath) {
        return new Intent(context, ShowPictureActivity.class).
                putExtra(ShowPictureActivity.INTENT_PIC, picpath);
    }

    public static Intent createIntent2(Context context, String picpath, boolean haveNavi) {
        return new Intent(context, ShowPictureActivity.class)
                .putExtra(ShowPictureActivity.INTENT_NAVI, haveNavi)
                .putExtra(ShowPictureActivity.INTENT_PIC, picpath);
    }


    @Override
    public Activity getActivity() {
        return this;
    }

    private String _picpath;
    boolean _haveNavi = false;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.showpicture_activity, this);//传this是为了全局滑动返回

        _picpath = getIntent().getStringExtra(INTENT_PIC);
        _haveNavi = getIntent().getBooleanExtra(INTENT_NAVI, _haveNavi);

        if (StringUtil.isNotEmpty(_picpath, true) == false) {
            Log.e(TAG, "initData  StringUtil.isNotEmpty(url, true) == false >> finish(); return;");
            enterAnim = exitAnim = R.anim.null_anim;
            finish();
            return;
        }

        //功能归类分区方法，必须调用<<<<<<<<<<
        initView();
        initData();
        initEvent();
        //功能归类分区方法，必须调用>>>>>>>>>>

    }


    //UI显示区(操作UI，但不存在数据获取或处理代码，也不存在事件监听代码)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    private ImageView ivPicture;

    @Override
    public void initView() {
        autoSetTitle();
        ivPicture = (ImageView) findViewById(R.id.ivPicture);
        if (_haveNavi) {
            findViewById(R.id.btn_navi).setVisibility(View.VISIBLE);
        } else {
            findViewById(R.id.btn_navi).setVisibility(View.GONE);
        }
    }


    //UI显示区(操作UI，但不存在数据获取或处理代码，也不存在事件监听代码)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


    //Data数据区(存在数据获取或处理代码，但不存在事件监听代码)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    @Override
    public void initData() {
        ImageLoaderUtil.loadImage(ivPicture, _picpath);
    }


    //Data数据区(存在数据获取或处理代码，但不存在事件监听代码)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


    //Event事件区(只要存在事件监听代码就是)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    @Override
    public void initEvent() {

    }

    @Override
    public void onDragBottom(boolean rightToLeft) {
        if (rightToLeft) {
            return;
        }
        onBackPressed();
    }

    @Override
    public void onReturnClick(View v) {
        finish();
    }

    @Override
    public void onForwardClick(View v) {
        //top栏右边按钮响应

        if (_haveNavi) {
            setResult(106);
        }
        finish();
    }


    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.tvBaseTitle) {

        }
    }

    //系统自带监听方法<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    @Override
    public void onBackPressed() {
        super.onBackPressed();
    }

    //类相关监听<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    @Override
    protected void onPause() {
        super.onPause();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }


    //类相关监听>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    //系统自带监听方法<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


    //Event事件区(只要存在事件监听代码就是)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


}